package com.zzb.text.dao;

import com.zzb.text.entity.Params;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by ZZB on 2017/6/16.
 */
@Mapper
public interface ParamsMapper {
    @Results(id = "params", value = {
            @Result(property = "id", column = "id", id = true),
            @Result(property = "key", column = "key"),
            @Result(property = "value", column = "value"),
    })
    @Select("select * from t_param")
    List<Params> findAll();

    @ResultMap("params")
    @Select("select * from t_param where id = #{id}")
    Params getOne(String id);

    @Insert("insert into t_param (`id`,`key`,`value`) value (uuid(),#{key},#{value})")
    void insert(Params params);

    @Update("update t_param set `key` = #{key}, `value` = #{value} where id = #{id}")
    void update(Params params);

    @Delete("delete from t_param where id = #{id}")
    void delete(String id);
}
